package com.mhwx.mhlive.ui.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.mhwx.mhlive.R;
import com.mhwx.mhlive.model.UserContent;
import com.mhwx.mhlive.ui.adapter.UserAdapter;
import com.mhwx.mhlive.ui.base.BaseFragment;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

/**
 * 类功能描述
 *
 * @author Guol
 * @version 1.0
 * @copyright 北京明华维新信息技术有限公司
 * @time 2017/4/21
 */
public class MeFragment extends BaseFragment {
    @BindView(R.id.user_list)
    RecyclerView userList;
    private UserAdapter userAdapter;
    private List<UserContent> configs;
    @Override
    protected int getLayoutRes() {
        return R.layout.frm_me;
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);

        init();
    }
  private void init(){
      configs = new ArrayList<>();
      userAdapter = new UserAdapter(getContext());
      userList.setLayoutManager(new LinearLayoutManager(getContext()));
      userList.setAdapter(userAdapter);
  }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public void onResume() {
        super.onResume();
        initList();
        userAdapter.updateItems(configs);
        userList.setAdapter(userAdapter);
    }
    private void initList() {
        if (configs != null && configs.size() > 0)
            configs.clear();
        configs.add(new UserContent("A", UserContent.HEADER, "header", 0, false));
        configs.add(new UserContent("B", UserContent.ITEM, "视频", R.drawable.user_order, false));
        configs.add(new UserContent("C", UserContent.ITEM, "收益", R.drawable.user_message, false));
        configs.add(new UserContent("D", UserContent.ITEM, "账户", R.drawable.user_friends, false));
        configs.add(new UserContent("E", UserContent.ITEM, "实名认证", R.drawable.user_about_us, false));
        //configs.add(new UserContent("F", UserContent.ITEM, "意见反馈", R.drawable.user_feedback,false));
        configs.add(new UserContent("G", UserContent.ITEM, "设置", R.drawable.user_setting, false));
    }
}
